const fs = require('fs');

fs.readFile('./bar.txt', (err, data) => {
    fs.writeFile('./test.txt', data, (err) => {
        console.log(err);
    })
})

// Stream的写法
const reader = fs.createReadStream('./foo.txt');
const writer = fs.createWriteStream('./test1.txt');

reader.pipe(writer);